home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics Plus
/
Graphics Plus.iso
/
general
/
viewers
/
polyview
/
polyvw31.lha
/
Polyview3.1
/
new
/
pvtime.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-13
|
17KB
|
480 lines
/*****************************************************************************
* NCSA Polyview 3.1 *
* *
* Version 3.1 changes and additions by Gilles Bourhis. *
* Version 3 changes and additions by Marc Andreessen. *
* Version 2 by Brian Calvert. *
* *
* Software Development Group *
* National Center for Supercomputing Applications *
* University of Illinois at Urbana-Champaign *
* *
* This is BETA release software. As such it may contain software bugs and *
* exhibit inconsistencies. *
* *
* Please send bug reports to polyview@ncsa.uiuc.edu. *
* *
* Copyright (c) 1992 The Board of Trustees of the University of Illinois. *
* *
* Permission to use, copy, and modify this software and its *
* documentation for educational, research, and non-profit purposes is *
* hereby granted, provided that the above copyright notice, the original *
* authors names, and this permission notice appear in all such copies. *
* Any distribution of this software requires the explicit and written *
* authorization of the authors. *
* *
* The University of Illinois makes no representations about the *
* suitability of this software for any purpose. It is provided "as is" *
* without warranty of any kind. *
*****************************************************************************/
/* $Id: pvtime.c,v 1.3 93/08/13 13:59:30 gbourhis Exp $ */
#ifdef RCSLOG
$Log: pvtime.c,v $
* Revision 1.3 93/08/13 13:59:30 gbourhis
* Add transcript of commands, change Version Number.
*
* Revision 1.2 92/09/24 03:13:14 marca
* Update text widget when sliders move.
*
* Revision 1.1 1992/09/18 10:55:26 marca
* Initial revision
*
#endif
#include "pv.h"
/* --------------------------- BITMAP INCLUDES ---------------------------- */
#include "forward.bm"
#include "forwardstep.bm"
#include "stop.bm"
#include "reversestep.bm"
#include "reverse.bm"
/* Static local variable to indicate that slider movement triggered the
last action, so init_animate shouldn't be called from notify_animate. */
static int last_action_from_gui = 0;
/* ----------------------------- local_reset ------------------------------ */
static int local_reset(state_t *state, window_t *win, void *w)
{
FOR_EACH_ACTIVE(win, state)
animate_reset(state, win);
init_animate(state, state->active_windows, win, TRUE);
return ST_OKAY;
}
/* --------------------------- init_animate_fn ---------------------------- */
int init_animate_fn(state_t *state, window_t *win, int reset)
{
return init_animate(state, state->active_windows, win, reset);
}
/* ----------------------------- init_animate ----------------------------- */
int init_animate (state_t *state, window_t *active, window_t *palette,
int reset)
{
animate_t *anim;
assert (state->animate_window != NULL);
anim = (animate_t *)WIN_IMAGE(state->animate_window);
if ((active == NULL) || (WIN_FRAMELIST(active) == NULL) ||
(WIN_FRAMES(active) == 1))
{
/* No active window or frame. Empty the window. */
/* Make everything unsensitive unless it already is. */
if (!anim->blank)
{
anim->blank = 1;
XmxSetSensitive (anim->frame, XmxUnsensitive);
XmxSetSensitive (anim->forward, XmxUnsensitive);
XmxSetSensitive (anim->forward_step, XmxUnsensitive);
XmxSetSensitive (anim->stop, XmxUnsensitive);
XmxSetSensitive (anim->reverse_step, XmxUnsensitive);
XmxSetSensitive (anim->reverse, XmxUnsensitive);
XmxSetSensitive (anim->frametext, XmxUnsensitive);
XmxSetSensitive (anim->delay, XmxUnsensitive);
XmxSetSensitive (anim->skip, XmxUnsensitive);
XmxSetSensitive (anim->frame_label, XmxUnsensitive);
XmxSetSensitive (anim->delay_label, XmxUnsensitive);
XmxSetSensitive (anim->skip_label, XmxUnsensitive);
/* Set value of frame scale to 1. */
XmxAdjustScale (anim->frame, 1);
/* Set value of skip scale to 0. */
XmxAdjustScale (anim->skip, 0);
/* Set the frame text to nothing. */
XmxTextSetString (anim->frametext, "");
}
}
else
{
/* First we need to unblank everything. */
if (anim->blank)
{
anim->blank = 0;
XmxSetSensitive (anim->frame, XmxSensitive);
XmxSetSensitive (anim->forward, XmxSensitive);
XmxSetSensitive (anim->forward_step, XmxSensitive);
XmxSetSensitive (anim->stop, XmxSensitive);
XmxSetSensitive (anim->reverse_step, XmxSensitive);
XmxSetSensitive (anim->reverse, XmxSensitive);
XmxSetSensitive (anim->frametext, XmxSensitive);
XmxSetSensitive (anim->delay, XmxSensitive);
XmxSetSensitive (anim->skip, XmxSensitive);
XmxSetSensitive (anim->frame_label, XmxSensitive);
XmxSetSensitive (anim->delay_label, XmxSensitive);
XmxSetSensitive (anim->skip_label, XmxSensitive);
}
if (!last_action_from_gui)
{
/* Set the frame slider max and current frame number values. */
XmxSetArg (XmNmaximum, (int)WIN_FRAMES(active));
XmxAdjustScale (anim->frame, WIN_FRAMEID(active));
/* Copy slider values and field value from the active window */
/* to the dialog's local variables. */
XmxAdjustScale (anim->delay, WIN_DELAY(active));
if (WIN_FRAMES(active) / 2 - 1 > 1)
XmxSetArg (XmNmaximum, WIN_FRAMES(active) / 2 - 1);
else
XmxSetArg (XmNmaximum, 1);
XmxAdjustScale (anim->skip, WIN_SKIP(active));
}
/* Frame text. */
XmxTextSetString (anim->frametext, FRA_NAME(WIN_FRAME(active)));
}
return ST_OKAY;
}
/* ------------------------------ CALLBACKS ------------------------------- */
static XmxCallback (GUItimeScaleCB)
{
char line[MAXLINELEN];
int val = ((XmScaleCallbackStruct *)call_data)->value;
animate_t *anim = (animate_t *)WIN_IMAGE(gstate->animate_window);
switch (XmxExtractToken ((int)client_data))
{
case PV_TIME_FRAME_SCALE:
PLAYAFILE ("/usr/lib/sounds/prosonus/instr/woodblock.aiff");
if (val != WIN_FRAMEID(gstate->active_windows))
{
animate_goto_num (gstate, gstate->active_windows, val);
sprintf (line, "time goto number %d\0", val);
GUIaddCommand (line);
TRANSaddCommand(gstate, line);
last_action_from_gui = 1;
}
break;
case PV_TIME_DELAY_SCALE:
PLAYAFILE ("/usr/lib/sounds/prosonus/instr/woodblock.aiff");
if (val != WIN_DELAY(gstate->active_windows))
{
time_delay (gstate, gstate->active_windows, val);
sprintf (line, "time delay %d\0", val);
GUIaddCommand (line);
TRANSaddCommand(gstate, line);
last_action_from_gui = 1;
}
break;
case PV_TIME_SKIP_SCALE:
PLAYAFILE ("/usr/lib/sounds/prosonus/instr/woodblock.aiff");
if (val != WIN_SKIP(gstate->active_windows))
{
time_skip (gstate, gstate->active_windows, val);
sprintf (line, "time skip %d\0", val);
GUIaddCommand (line);
TRANSaddCommand(gstate, line);
last_action_from_gui = 1;
}
break;
}
return;
}
static XmxCallback (GUItimeVCRButtonCB)
{
switch (XmxExtractToken ((int)client_data))
{
case PV_TIME_FRAME_FORWARD:
PLAYAFILE ("/usr/lib/sounds/prosonus/instr/braz_hi_shaker.aiff");
parse_line (gstate, "time forward", TRUE);
break;
case PV_TIME_FRAME_FORWARDSTEP:
PLAYAFILE ("/usr/lib/sounds/prosonus/instr/drm_clave.aiff");
parse_line (gstate, "time forward step", TRUE);
break;
case PV_TIME_FRAME_STOP:
PLAYAFILE ("/usr/lib/sounds/prosonus/instr/tama_base_drm.aiff");
parse_line (gstate, "time stop", TRUE);
break;
case PV_TIME_FRAME_REVERSESTEP:
PLAYAFILE ("/usr/lib/sounds/prosonus/instr/drm_clave.aiff");
parse_line (gstate, "time reverse step", TRUE);
break;
case PV_TIME_FRAME_REVERSE:
PLAYAFILE ("/usr/lib/sounds/prosonus/instr/braz_hi_shaker.aiff");
parse_line (gstate, "time reverse", TRUE);
break;
}
return;
}
static XmxCallback (GUItimeVCRTextCB)
{
char line[MAXLINELEN];
sprintf (line, "time goto %s\0", XmxTextGetString (w));
parse_line (gstate, line, TRUE);
return;
}
static XmxCallback (GUItimeButtonCB)
{
switch (XmxExtractToken ((int)client_data))
{
case PV_TIME_BUTTON_HELP:
GUIdoHelp (PV_TIME_BUTTON_HELP);
break;
case PV_TIME_BUTTON_OK:
/* NO NO NO NO! */
/* XtUnmanageChild (gstate->animate_window->base); */
parse_line (gstate, "window close time", TRUE);
break;
case PV_TIME_BUTTON_RESET:
PLAYAFILE ("/usr/lib/sounds/prosonus/sfx/tennis.aiff");
parse_line (gstate, "time reset", TRUE);
break;
}
return;
}
/* ------------------------ create_animate_dialog ------------------------- */
void *create_animate_dialog (state_t *state)
{
window_t *win;
animate_t *anim;
Widget dialog_frame;
Widget time_form, buttons_form;
Widget dialog_sep;
Widget control_form, row_frame, row_form;
Widget frame_label, delay_label, skip_label;
/* Make the new time window. */
state->animate_window = win = add_window
(state, "time", DIALOG /* fuck it */,
NULL /* init */,
NULL /* redraw */,
NULL /* animate */,
NULL /* event */,
notify_animate /* notify */,
destroy_animate /* destroy */);
win->id = 0;
XmxSetUniqid (win->id);
win->base = XmxMakeFormDialog (state->base, "Polyview 3.1: Time Window");
win->image = anim = (animate_t *)PVMALLOC (sizeof (animate_t));
/* When we start out we're not blank. */
anim->blank = 0;
/* Frame for dialog box. */
dialog_frame = XmxMakeFrame (win->base, XmxShadowOut);
/* Constraints for base. */
XmxSetConstraints
(dialog_frame, XmATTACH_FORM, XmATTACH_FORM, XmATTACH_FORM, XmATTACH_FORM,
NULL, NULL, NULL, NULL);
/* Form for dialog box components. */
time_form = XmxMakeForm (dialog_frame);
/* Controls go in one big form. */
XmxSetArg (XmNhorizontalSpacing, 10);
control_form = XmxMakeForm (time_form);
anim->frame_label = XmxMakeLabel (control_form, "Frame:");
anim->frame = XmxMakeScale
(control_form, GUItimeScaleCB, PV_TIME_FRAME_SCALE, NULL, 1, 100, 50, 0);
/* Make frame and form to hold five buttons and one text widget. */
row_frame = XmxMakeFrame (control_form, XmxShadowEtchedOut);
XmxSetArg (XmNhorizontalSpacing, 5);
XmxSetArg (XmNverticalSpacing, 5);
row_form = XmxMakeForm (row_frame);
anim->reverse = XmxMakeBlankButton
(row_form, GUItimeVCRButtonCB, PV_TIME_FRAME_REVERSE);
XmxApplyBitmapToLabelWidget
(anim->reverse, reverse_bits, reverse_width, reverse_height);
anim->reverse_step = XmxMakeBlankButton
(row_form, GUItimeVCRButtonCB, PV_TIME_FRAME_REVERSESTEP);
XmxApplyBitmapToLabelWidget
(anim->reverse_step, reversestep_bits, reversestep_width,
reversestep_height);
anim->stop = XmxMakeBlankButton
(row_form, GUItimeVCRButtonCB, PV_TIME_FRAME_STOP);
XmxApplyBitmapToLabelWidget
(anim->stop, stop_bits, stop_width, stop_height);
anim->forward_step = XmxMakeBlankButton
(row_form, GUItimeVCRButtonCB, PV_TIME_FRAME_FORWARDSTEP);
XmxApplyBitmapToLabelWidget
(anim->forward_step, forwardstep_bits, forwardstep_width,
forwardstep_height);
anim->forward = XmxMakeBlankButton
(row_form, GUItimeVCRButtonCB, PV_TIME_FRAME_FORWARD);
XmxApplyBitmapToLabelWidget
(anim->forward, forward_bits, forward_width, forward_height);
anim->frametext = XmxMakeText (row_form);
/* Activate callback; passed in as parameter. */
XmxAddCallbackToText (anim->frametext, GUItimeVCRTextCB, 0);
/* Constraints for row_form. */
XmxSetConstraints
(anim->reverse, XmATTACH_FORM, XmATTACH_FORM, XmATTACH_FORM, XmATTACH_NONE,
NULL, NULL, NULL, NULL);
XmxSetConstraints
(anim->reverse_step, XmATTACH_FORM, XmATTACH_FORM, XmATTACH_WIDGET,
XmATTACH_NONE, NULL, NULL, anim->reverse, NULL);
XmxSetConstraints
(anim->stop, XmATTACH_FORM, XmATTACH_FORM, XmATTACH_WIDGET, XmATTACH_NONE,
NULL, NULL, anim->reverse_step, NULL);
XmxSetConstraints
(anim->forward_step, XmATTACH_FORM, XmATTACH_FORM, XmATTACH_WIDGET,
XmATTACH_NONE, NULL, NULL, anim->stop, NULL);
XmxSetConstraints
(anim->forward, XmATTACH_FORM, XmATTACH_FORM, XmATTACH_WIDGET,
XmATTACH_NONE, NULL, NULL, anim->forward_step, NULL);
XmxSetArg (XmNleftOffset, 50);
XmxSetConstraints
(anim->frametext, XmATTACH_NONE, XmATTACH_FORM, XmATTACH_WIDGET,
XmATTACH_FORM, NULL, NULL, anim->forward, NULL);
XmxSetArg (XmNmarginBottom, 2);
anim->delay_label = XmxMakeLabel (control_form, "Delay:");
anim->delay = XmxMakeScale
(control_form, GUItimeScaleCB, PV_TIME_DELAY_SCALE, NULL, 0, 99, 0, 0);
XmxSetArg (XmNmarginBottom, 2);
anim->skip_label = XmxMakeLabel (control_form, "Skip:");
anim->skip = XmxMakeScale
(control_form, GUItimeScaleCB, PV_TIME_SKIP_SCALE, NULL, 0, 9, 0, 0);
/* Constraints for control_form. */
XmxSetArg (XmNtopOffset, 10);
XmxSetConstraints
(anim->frame_label, XmATTACH_FORM, XmATTACH_NONE, XmATTACH_FORM,
XmATTACH_NONE, NULL, NULL, NULL, NULL);
XmxSetConstraints
(anim->frame, XmATTACH_WIDGET, XmATTACH_NONE, XmATTACH_FORM, XmATTACH_FORM,
anim->frame_label, NULL, NULL, NULL);
XmxSetArg (XmNtopOffset, 10);
XmxSetConstraints
(row_frame, XmATTACH_WIDGET, XmATTACH_NONE, XmATTACH_FORM, XmATTACH_FORM,
anim->frame, NULL, NULL, NULL);
XmxSetArg (XmNtopOffset, 10);
XmxSetConstraints
(anim->delay_label, XmATTACH_WIDGET, XmATTACH_NONE, XmATTACH_FORM,
XmATTACH_NONE, row_frame, NULL, NULL, NULL);
XmxSetConstraints
(anim->delay, XmATTACH_WIDGET, XmATTACH_NONE, XmATTACH_FORM, XmATTACH_FORM,
anim->delay_label, NULL, NULL, NULL);
XmxSetArg (XmNtopOffset, 10);
XmxSetConstraints
(anim->skip_label, XmATTACH_WIDGET, XmATTACH_NONE, XmATTACH_FORM,
XmATTACH_NONE, anim->delay, NULL, NULL, NULL);
XmxSetConstraints
(anim->skip, XmATTACH_WIDGET, XmATTACH_NONE, XmATTACH_FORM, XmATTACH_FORM,
anim->skip_label, NULL, NULL, NULL);
dialog_sep = XmxMakeHorizontalSeparator (time_form);
buttons_form = XmxMakeFormAndThreeButtons
(time_form, GUItimeButtonCB, "OK", "Reset", "Help",
PV_TIME_BUTTON_OK, PV_TIME_BUTTON_RESET, PV_TIME_BUTTON_HELP);
/* Constraints for time_form. */
XmxSetConstraints
(control_form, XmATTACH_FORM, XmATTACH_NONE, XmATTACH_FORM, XmATTACH_FORM,
NULL, NULL, NULL, NULL);
XmxSetArg (XmNtopOffset, 10);
XmxSetConstraints
(dialog_sep, XmATTACH_WIDGET, XmATTACH_WIDGET, XmATTACH_FORM,
XmATTACH_FORM, control_form, buttons_form, NULL, NULL);
XmxSetConstraints
(buttons_form, XmATTACH_NONE, XmATTACH_FORM, XmATTACH_FORM, XmATTACH_FORM,
NULL, NULL, NULL, NULL);
init_animate(state, state->active_windows, NULL, FALSE);
XmxManageRemanage (win->base);
return;
}
/* ---------------------------- notify_animate ---------------------------- */
int notify_animate (state_t * state, window_t * send_win, window_t * recv_win,
int message, va_list args)
{
int status;
status = ST_OKAY;
switch (message)
{
case MSG_NEWACT:
/* Catch 'time reset', hopefully. */
init_animate(state, send_win, recv_win, TRUE);
last_action_from_gui = 0;
break;
case MSG_NEWFRAME:
case MSG_NEWDATA:
case MSG_VIEWCHG:
case MSG_CLOSING:
case MSG_RESET:
/* Only update the window if this is the current window. */
if (send_win == state->active_windows)
{
init_animate(state, send_win, recv_win, FALSE);
last_action_from_gui = 0;
}
break;
case MSG_NEWPICK:
default:
break;
}
return status;
}
/* --------------------------- destroy_animate ---------------------------- */
int destroy_animate (state_t *state, window_t *window)
{
/* do absolutely nothing */
return ST_OKAY;
}